package org.pentaho.cubic.client.dialogs;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;

public class DemoDialog extends DialogBox {
	
	public DemoDialog() {
		super();
		setHTML("New dialog");
	}

	public DemoDialog(String title, String text) {

		super();
		
		this.setAutoHideEnabled(true);
		this.setGlassEnabled(true);
		this.setText(title);
		
	    // Create a table to layout the content
	    VerticalPanel dialogContents = new VerticalPanel();
	    dialogContents.setSpacing(4);
	    this.setWidget(dialogContents);

	    // Add some text to the top of the dialog
	    HTML details = new HTML(text);
	    dialogContents.add(details);
	    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

	    // Add a close button at the bottom of the dialog
		Button okButton = new Button("OK");
		okButton.addClickHandler(new ClickHandler() {
	        public void onClick(ClickEvent event) {
	        	DemoDialog.this.hide();
	        }
	    });
	    dialogContents.add(okButton);
	    dialogContents.setCellHorizontalAlignment(okButton, HasHorizontalAlignment.ALIGN_CENTER);

	}
}
